import React,{useReducer} from 'react';
import { Card, Breadcrumb, Layout } from 'antd';

import ComponPower from '../../components/componPower'
import Modelmes from '../../components/Modelmes'
import TableList from '../../components/Mycompon/TableList'
/**
 * 权限管理接口
 *
 * 接口统一返回格式
 *  { data: Object, code: number, msg: string },
 *  code: 接口返回状态
 *  data: 返回数据
 *  msg:  返回信息
 */
import { getAuthList, editAuth, addAuth } from '../../api/auth/index';
const { Content } = Layout;


//数据仓库

const initialState = {
  user: { id: 1, name: 'Lisi' },
  friends: ['LiLei', 'HanMeiMei'],
  switch:false,
  //权限的搜索状态 
  search:{}

};

const reducer = (state, action) => {
  console.log("权限查询获取到的数据",action);
 
  switch (action.type) {
    case 'addFriends':
      return {
        ...state,
        friends: [...state.friends, action.name],
      };
    case 'modifyName':
      return {
        ...state,
        user: { ...state.user, name: action.name },
      };
      case 'changeSwitch':
      return {
        ...state,
        switch: action.name
      };
      case 'QXsearch':
      return{
        ...state,
        search: action.obj
      };
      case 'addTab':
        return{
          ...state,
          addObj: action.obj
        };

}
}

function NewService1() {
  const [store, dispatch] = useReducer(reducer, initialState);
  return (
    <>
    <Card>
      <Breadcrumb separator=">">
        <Breadcrumb.Item href="/services">角色管理</Breadcrumb.Item>
        <Breadcrumb.Item href="/services/1">权限管理</Breadcrumb.Item>
      </Breadcrumb>

      <Content  style={{ margin: '1px 0 5px 5px' }}>
        <p>权限管理</p>
      </Content>
    </Card>

  
      
      <Layout>
       
        <Content style={{ margin: "15px",background: "#fff"}}>
        <ComponPower store={store} dispatch={dispatch}/>
        <Modelmes store={store} dispatch={dispatch}/>
        
        <TableList store={store} dispatch={dispatch}/>
        </Content>

      </Layout>

</>
    
    
  );
}

export default NewService1;
